package yxy.cherry.battle.module.selector;

import yxy.cherry.battle.Fighter;
import yxy.cherry.battle.Team;

import java.util.ArrayList;
import java.util.Comparator;
import java.util.Set;

@TargetSelectorType(Type = 26)
public class TargetSelector_26_怒气排序 extends TargetSelector {

	@Override
	public Set<Fighter> target(Fighter actor, Team team, int param1, int param2) {
		ArrayList<Fighter> list = sort怒气(team);
		return getSpecialFighter(actor,list,param1,param2);
	}

	private ArrayList<Fighter> sort怒气(Team team) {
		ArrayList<Fighter> list = new ArrayList<Fighter>(team.get活人());
		list.sort(new Comparator<Fighter>() {

			@Override
			public int compare(Fighter o1, Fighter o2) {
				if (!o1.is活着()) {
					return -1;
				}
				int value = o1.getAnger() > o2.getAnger() ? 1 : -1;
				if (o1.getAnger() == o2.getAnger()) {
					return o2.getPosition().getValue() - o1.getPosition().getValue();
				}
				return value;
			}
		});


		return list;
	}
}